home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0018_Extended Keys.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  3KB  |  102 lines

  1. { MICHAEL NICOLAI }
  2.  
  3. Uses
  4.   Dos;
  5.  
  6. Function Get_Extended_KeyCode : Word;
  7. Var
  8.   regs : Registers;
  9. begin
  10.   regs.ah := $10;
  11.   intr($16, regs);
  12.   Get_Extended_KeyCode := (regs.ah shl 4) + regs.al;
  13. end;
  14.  
  15. {
  16. This Function waits Until a key is pressed.  The upper Byte contains the
  17. scan code, the lower Byte contains the ASCII code.  If you don't want your
  18. Program to hang if no key is pressed, use this funtion to check if any
  19. keycode is actually present in the keyboard buffer:
  20. }
  21.  
  22. Function Check_For_Extended_KeyStroke : Boolean;  { like KeyPressed }
  23. Var
  24.   regs : Registers;
  25. begin
  26.   regs.ah := $11;
  27.   intr($16, regs);
  28.   Check_For_Extended_Keystroke := False;
  29.   if ((regs.flags and fzero) = 0) then
  30.     Check_For_Extended_Keystroke := True;
  31. end;
  32.  
  33. {
  34. After this Function returns True, the keycode can be read With
  35. 'Get_Extended_KeyCode'.
  36.  
  37. Here are the routines my Functions are based on:
  38.  
  39. INTERRUPT 16h - Function 10h
  40. Keyboard - Get enhanced keystroke
  41.  
  42. Purpose: Wait For any keyboard input.
  43. Available on: AT or PS/2 With enhanced keyboard support only.
  44. Restrictions: none.
  45. Registers at call: AH = 10h.
  46. Return Registers: AH = scan code, AL = ASCII code
  47. Details: if no keystroke is available, this Function waits Until one is
  48.          placed in the keyboard buffer. Unlike Function 00h, this Function
  49.          does not discard extended keystrokes.
  50. Conflicts: none known.
  51.  
  52.  
  53. INTERRUPT 16h - Function 11h
  54. Keyboard - Check For enhanced keystroke
  55.  
  56. Purpose: Checks For availability of any keyboard input.
  57. Available on: AT or PS/2 With enhanced keyboard only.
  58. Restrictions: none.
  59. Registers at call: AH = 11h
  60. Return Registers: ZF set if no keystroke available
  61.                   ZF clear if keystroke available
  62.                      AH = scan code
  63.                      AL = ASCII code
  64. Details: if a keystroke is available, it is not removed from the keyboard
  65.          buffer. Unlike Function 01h, this Function does not discard extended
  66.          keystrokes.
  67. conflicts: none known.
  68.  
  69.  
  70. INTERRUPT 16h - Function 12h
  71. Keyboard - Get extended shift states
  72.  
  73. Purpose: Returns all shift-flags information from enhanced keyboards.
  74. Available: AT or PS/2 With enhanced keyboard only.
  75. Restrictions: none.
  76. Registers at call: AH = 12h
  77. Return Registers: AL = shift flags 1 (same as returned by Function 02h):
  78.                        bit 7: Insert active
  79.                            6: CapsLock active
  80.                            5: NumLock active
  81.                            4: ScrollLock active
  82.                            3: Alt key pressed (either Alt on 101/102-key
  83.                               keyboard)
  84.                            2: Crtl key pressed (either Ctrl on 101/102-key
  85.                               keyboard)
  86.                            1: left shift key pressed
  87.                            0: right shift key pressed
  88.  
  89.                   AH = shift flags 2:
  90.                        bit 7: SysRq key pressed
  91.                            6: CapsLock pressed
  92.                            5: NumLock pressed
  93.                            4: ScrollLock pressed
  94.                            3: right Alt key prssed
  95.                            2: right Ctrl key pressed
  96.                            1: left Alt key pressed
  97.                            0: left Ctrl key pressed
  98. Details: AL bit 3 is set only For left Alt key on many machines. AH bits 7
  99.          through 4 are always clear on a Compaq SLT/286.
  100. Conflicts: none known.
  101. }
  102.